package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.utils.UserThreadLocal;
import com.zzyl.nursing.dto.*;
import com.zzyl.nursing.domain.FamilyMemberElder;
import com.zzyl.nursing.service.IDeviceDataService;
import com.zzyl.nursing.service.IDeviceService;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.DeviceDataGraphVo;
import com.zzyl.nursing.vo.FamilyMemberElderVo;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.MemberElderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 *
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController {
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto) {
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    /**
     * 熊天雨-按天统计查询指标数据
     *
     * @return
     */
    @GetMapping("queryDeviceDataListByDay")
    public R<List<DeviceDataGraphVo>> queryDeviceDataListByDay(DayTimeQueryDto dataDto) {
        List<DeviceDataGraphVo> deviceDataGraphVos = familyMemberService.queryDeviceDataListByDay(dataDto);
        return R.ok(deviceDataGraphVos);
    }
    /**
     * 绑定家人
     */
    @PostMapping("add")
    @ApiOperation("绑定家人")
    public R bindingFamily(@RequestBody MemberElderDto memberElderDto) {
        familyMemberService.bindingFamily(memberElderDto);
        return R.ok();
    }

    /**
     * 熊天雨-按周统计查询指标数据
     *
     * @param timeQueryDto
     * @return
     */
    @GetMapping("queryDeviceDataListByWeek")
    public R<List<DeviceDataGraphVo>> queryDeviceDataListByWeek(DayTimeQueryDto timeQueryDto) {
        List<DeviceDataGraphVo> list = familyMemberService.queryDeviceDataListByWeek(timeQueryDto);
        return R.ok(list);
    }
    /**
     * 查询家人列表
     */
    @GetMapping("my")
    @ApiOperation("查询家人列表")
    public R selectFamily() {
        List<FamilyMemberElderVo> familyMemberElder = familyMemberService.selectFamily();
        return R.ok(familyMemberElder);
    }

    /**
     * 熊天雨-查询健康数据
     *
     * @param memberDeviceDto
     * @return
     */
    @PostMapping("QueryDevicePropertyStatus")
    public R<MemberDeviceVO> queryDevicePropertyStatus(@RequestBody MemberDeviceDto memberDeviceDto) {
        MemberDeviceVO memberDeviceVO = familyMemberService.queryDevicePropertyStatus(memberDeviceDto);
        return R.ok(memberDeviceVO);
    }

    /**
     * 分页查询已绑定家人列表
     */
    @GetMapping("list-by-page")
    @ApiOperation("分页查询已绑定的家人列表")
    public R pageSelectFamily(Integer pageNum, Integer pageSize) {
        List<MemberElderVo> list =familyMemberService.pageSelectFamily(pageNum,pageSize);
        return R.ok(list);
    }
}
